#include <cstdlib>
#include <ctime>
#include <GL/glu.h>
#include <GL/gl.h>

void slBox(float x, float y, float z)
{
	glPushMatrix();
	glScalef(x,y,z);

	glDisable(GL_TEXTURE_2D);
	glBegin (GL_QUADS);

	glNormal3f(0.0f, 0.0f, -1.0f); // Normal face derriere
	glTexCoord2i(0,0);	glVertex3i(-1,-1,-1);
	glTexCoord2i(1,0);	glVertex3i(+1,-1,-1);
	glTexCoord2i(1,1);	glVertex3i(+1,+1,-1); 
	glTexCoord2i(0,1);	glVertex3i(-1,+1,-1);

	glNormal3f(0.0f, 0.0f, 1.0f); // Normal face devant
	glTexCoord2i(0,0);	glVertex3i(-1,-1,+1);
	glTexCoord2i(1,0);	glVertex3i(+1,-1,+1); 
	glTexCoord2i(1,1);	glVertex3i(+1,+1,+1); 
	glTexCoord2i(0,1);	glVertex3i(-1,+1,+1);

	glNormal3f(1.0f, 0.0f, 0.0f); // Normal face droite
	glTexCoord2i(0,0);	glVertex3i(+1,-1,-1); 
	glTexCoord2i(1,0);	glVertex3i(+1,-1,+1);
	glTexCoord2i(1,1);	glVertex3i(+1,+1,+1);
	glTexCoord2i(0,1);	glVertex3i(+1,+1,-1);


	glNormal3f(-1.0f, 0.0f, 0.0f); // Normal face gauche
	glTexCoord2i(0,0);	glVertex3i(-1,-1,-1); 
	glTexCoord2i(1,0);	glVertex3i(-1,-1,+1); 
	glTexCoord2i(1,1);	glVertex3i(-1,+1,+1);
	glTexCoord2i(0,1);	glVertex3i(-1,+1,-1);


	glNormal3f(0.0f, 1.0f, 0.0f); // Normal face haut
	glTexCoord2i(1,0);	glVertex3i(-1,+1,-1); 
	glTexCoord2i(1,1);	glVertex3i(+1,+1,-1); 
	glTexCoord2i(0,1);	glVertex3i(+1,+1,+1);
	glTexCoord2i(0,0);	glVertex3i(-1,+1,+1);

	glNormal3f(0.0f, -1.0f, 0.0f); // Normal face bas
	glTexCoord2i(1,0);	glVertex3i(-1,-1,+1); 
	glTexCoord2i(1,1);	glVertex3i(+1,-1,+1);
	glTexCoord2i(0,1);	glVertex3i(+1,-1,-1);
	glTexCoord2i(0,0);	glVertex3i(-1,-1,-1);

	glEnd();
	glEnable(GL_TEXTURE_2D);

	glPopMatrix();
}

float slRand(int max)
{
	return rand() % max;
}